<script>
var filePath = "";
var fileName = "";
var appRegFilePath = "";
var appRegFileName = "";
$("#paperFileName").val("请选择上传的文件！").show();
//$("#appRegFileName").val("请选择上传的文件！").show();
$(function(){
    /* $("#uploadPaperFile").on("change",function(){
        filePath=$(this).val();
        //alert("filepath====>"+filePath);
        if(filePath!=""&&(typeof filePath)!='undefined'){
            var arr=filePath.split('\\');
            fileName=arr[arr.length-1];
            $("#paperFileName").val(fileName);
        }else{
        	fileName="";
            $("#paperFileName").val("请选择上传的文件！").show();
            
        }
        return false
    });
    
    $("#cancelPaperFile").on("click",function(){
    	 $("#uploadPaperFile").val(""); 
		 $("#paperFileName").val("请选择上传的文件！");
		 return false
    });
    $("#paperFileSubmit").on("click",function(){
    	//var dataForm = {"filePath":filePath,"fileName":fileName};
    	if($("#uploadPaperFile").get(0).files.length==0){
    		alert("请先选择要上传的文件！");
    	}else{
    		var uploadFileRes = $("#uploadPaperFile").get(0).files[0];
    		var formData1 = new FormData();
    		formData1.append("file",uploadFileRes);
    		 $.ajax({
    			 type:"POST",
    			 url:"applicationSingle/uploadFile",
    			 data:formData1,
    			 processData : false,
    			 dataType:"json",
    			 contentType : false ,
    			 cache: false,
    			 success:function(response){
    				 alert("文件上传成功！");
					  $("#uploadPaperFile").val(""); 
    				 var aa = document.getElementById("paperFileName").value; 
    				 $('#span_id').html(aa+"上传成功！");
    				 $("#uploadPaperFile").val(""); 
    				 $("#paperFileName").val("请选择上传的文件！");
    			 },
    			 error: DWZ.ajaxError	 
    		 });
    	} 	
    }); */
    
    $("#uploadAppRegFile").on("change",function(){
        appRegFilePath=$(this).val();
        //alert("filepath====>"+filePath);
        if(appRegFilePath!=""&&(typeof appRegFilePath)!='undefined'){
           var ff =  this.files
           var s = "";
            for(var i=0;i<ff.length;i++){
            	if(i == ff.length-1 ){
            		s += ff[i].name
            	}else{
            		s += ff[i].name+','
            	}
            }
          
            $("#appRegFileName").val(s);
        }else{
        	appRegFileName="";
            $("#appRegFileName").val("请选择上传的文件！").show();
            
        }
        return false
    });
    
    $("#cancelappRegFile").on("click",function(){
   	 $("#uploadAppRegFile").val(""); 
		 $("#appRegFileName").val("请选择上传的文件！");
		 return false
    });
    
     $("#appRegFileSubmit").on("click",function(){
    	//var dataForm = {"filePath":filePath,"fileName":fileName};
    	if($("#uploadAppRegFile").get(0).files.length==0){
    		alertMsg.error("请先选择要上传的文件！");
    	}else{
    		var formData2 = new FormData();
			var files = $("#uploadAppRegFile")[0].files
			for(var i=0;i<files.length;i++){
				formData2.append("files",files[i]);
			}
    		 $.ajax({
    			 type:"POST",
    			 url:"applicationSingle/uploadAppRegFile",
    			 data:formData2,
    			 processData : false,
    			 dataType:"json",
    			 contentType : false ,
    			 traditional:true,
    			 cache: false,
    			 success:dialogAjaxDone,
    			 error: DWZ.ajaxError	 
    		 });
    	}
    	return false;
    	
    }); 
    
  /*   $("#pay").click(function(){
    	var fee = $("#fee_principle").val();
    	if(fee==0){
    		alertMsg.warn("请选择收取的费用标准！！");
    		return false;
    	}
    	if(fee!=0){
    		alertMsg.confirm("请收费"+fee+"元！", {
        		okCall: function(){
        			$("#payFlag").val("true");
        		}
        	});
    		return false;
    	}
    }); */
    
  /*   $("#beforeSubmit").click(function(){
    	var feeFlag = $("#payFlag").val();
    	if(feeFlag){
			return true;
    	}else{
    		alertMsg.warn("请先收取费用！！");
    		return false;
    	}
    }); */
})
/* $(function(){
	$.get("applicationSingle/getfeeprinciple",function(json){
		$(json).each(function(n,item){
			if(typeof(item.fee) != "undefined"){
				$("input[name='fee_principle']").val(item.fee)
			}else{
				alertMsg.warn("收费定义不存在或者有效期过期")
			}

		})
	},"json");

}); */
</script>
<div class="pageContent">
	<form method="post" action="applicationSingle/toDatabaseRegistry" class="pageForm required-validate" onsubmit="return validateCallback(this, printViewPageAjaxDone);">
		<div class="pageFormContent" layoutH="56">
		<!-- <fieldset>
			<legend>附件上传</legend>
			<p>
				<input type="file" id="uploadPaperFile" name="uploadPaperFile" accept="application/pdf,image/png,image/jeg,image/gif,image/gif">
			</p>
			<p>
				<input type="text" id="paperFileName" name="paperFileName" size="50">
				<span id = "span_id" style="color:blue"></span>
			</p>
			<p>
				<input type="button"  id="paperFileSubmit" value="上传"/>
				<input type="button"  id="cancelPaperFile" value="取消"/>
			</p>
		</fieldset> -->
		 <fieldset>
			<legend>附件上传</legend>
			<p>
				<input type="file" id="uploadAppRegFile" multiple="multiple" name="uploadPaperFile" accept="application/pdf,image/png,image/jeg,image/gif,image/gif">
			</p>
			<p>
				<input type="text" id="appRegFileName" name="appRegFileName" size="50">
			</p>
			<p>
				<input type="button"  id="appRegFileSubmit" value="上传"/>
				<input type="button"  id="cancelappRegFile" value="取消"/>
			</p>
		</fieldset> 
		<!-- <fieldset>
			<legend>收费</legend>
			<p>
				<label>收费标准：</label>
				<select  id="fee_principle" name="fee_principle" >
					<option value="0">请选择</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
				</select>  元  
				<input id="fee_principle" name="fee_principle" class="required" readonly="readonly"> 元
			</p>
			<input id="payFlag" name="payFlag" value="" type="hidden">
		</fieldset> -->
		</div>
		<!-- <div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button id="pay">收费</button></div></div></li>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="beforeSubmit">提交</button></div></div></li>
				<li>
					<a class="button" href="applicationSingle/register" target="navTab" rel="ApplicationSingle" title="单笔申请" ><span>返回</span></a><br /><br />
				</li>				
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
				</li>
			</ul>
		</div> -->
	</form>
</div>

